/**
 * 
 */
package info.niwota.group;

import java.io.IOException;

import android.media.MediaRecorder;
import android.media.MediaRecorder.OnErrorListener;

/**
 * @author qiangli
 * 
 */
public class MyMediaRecorder implements AudioRecorder {
	private MediaRecorder recorder = null;

	public MyMediaRecorder() {
		super();
		recorder = new MediaRecorder();
	}

	public int getMaxAmplitude() throws IllegalStateException {
		return recorder.getMaxAmplitude();
	}

	public void prepare() throws IllegalStateException, IOException {
		recorder.prepare();
	}

	public void release() {
		recorder.release();
	}

	public void reset() {
		recorder.reset();
	}

	public void setAudioEncoder(int audioEncoder) throws IllegalStateException {
		recorder.setAudioEncoder(audioEncoder);
	}

	public void setAudioSource(int audioSource) throws IllegalStateException {
		recorder.setAudioSource(audioSource);
	}

	public void setOnErrorListener(OnErrorListener l) {
		recorder.setOnErrorListener(l);
	}

	public void setOutputFile(String path) throws IllegalStateException {
		recorder.setOutputFile(path);
	}

	public void setOutputFormat(String mimeType) throws IllegalStateException {
		int fmt = FileFormats.format(mimeType);
		recorder.setOutputFormat(fmt);
	}

	public void start() throws IllegalStateException {
		recorder.start();
	}

	public void stop() throws IllegalStateException {
		recorder.stop();
	}

	public void setSampleRate(int hz) {
		// TODO not supported yet
		// recorder.setParameters(String.format(
		// "audio-param-encoding-bitrate=%d", mProfile.mAudioBitrate));
		// recorder.setParameters(String.format(
		// "audio-param-number-of-channels=%d", mProfile.mAudioChannels));
		// recorder.setParameters(String.format(
		// "audio-param-sampling-rate=%d", mProfile.mAudioSamplingRate));
	}

	public int getBitRate() {
		return FileFormats.BITRATE_5900;
	}
}
